package axdoc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import axdoc.done.ThreadManager;

@Controller
@RequestMapping("thread")
public class ThreadController {

	@Autowired
	ThreadManager threadManager;

	@RequestMapping(value = "list")
	public ModelAndView rules(ModelAndView model) {
		model.addObject("activeCount", threadManager.getActiveCount());
		model.addObject("poolSize", threadManager.getPoolSize());
		model.addObject("maxPoolSize", threadManager.getMaxPoolSize());
		model.addObject("corePoolSize", threadManager.getCorePoolSize());
		model.setViewName("thread");
		return model;
	}

	@RequestMapping(value = "add")
	public String addThread() {
		threadManager.addThread();
		return "forward:list";
	}

	@RequestMapping(value = "remove")
	public String removeThread() {
		threadManager.removeThread();
		return "forward:list";
	}
}
